<?php
    header('content-type:text/html;charset-utf-8');

    $host = 'localhost:3306' ;
    $name = $pwd = 'root' ;
    $dbname = 'day24' ;
    $conn = mysqli_connect($host , $name , $pwd , $dbname) ;

    if(!$conn) {
        die('数据库连接失败');
    }


    $id = $_POST['id'];
    $obj = [];

    $sql = "select * from goods_list where goods_id = $id";

    $res = mysqli_query($conn , $sql);
    $arr = mysqli_fetch_array($res);

    $data = [];

    if($arr){
        $data['id'] = $arr['goods_id'] ;
        $data['name'] = $arr['goods_name'] ;
        $data['title'] = $arr['goods_title'] ;
        $data['des'] = $arr['goods_des'] ;
        $data['img'] = $arr['goods_img'] ;
        $data['price'] = $arr['goods_price'] ;
        $data['mode'] = $arr['goods_mode'] ;
        $data['sale'] = $arr['goodssale'] ;
        $data['type'] = $arr['goods_type'] ;

        $obj['status'] = true ;
        $obj['msg'] = '数据请求成功';
        $obj['data'] = $data ;
    }else{
        $obj['status'] = false ;
        $obj['msg'] = '数据请求失败';
    }

    echo(json_encode($obj,JSON_UNESCAPED_UNICODE));
?>